import { getOrderSettleInfoByOrderId } from '@/api/order'
import { ref } from 'vue'
import { OrderSettleInfo } from './types'

export default () => {
  // 获取结单信息加载
  const getOrderSettleInfoLoading = ref(false)

  // 工单结单信息
  const orderSettleInfo = ref<Array<OrderSettleInfo>>([])

  /**
   * 获取工单结单信息
   * @param {String} orderId - 工单id
   */
  const getOrderSettleInfo = async (orderId: string) => {
    getOrderSettleInfoLoading.value = true
    const res = await getOrderSettleInfoByOrderId(orderId)
    getOrderSettleInfoLoading.value = false
    orderSettleInfo.value = res.data.data.rows
  }

  return {
    orderSettleInfo,
    getOrderSettleInfoLoading,
    getOrderSettleInfo,
  }
}
